import { computed, watch } from "vue";
import { useRoute } from "vue-router";
import useTagsViewStore from "@/store/modules/tagsView";

export default () => {
  const route = useRoute();
  const tagsViewStore = useTagsViewStore();

  const cachedView = computed(() => {
    return tagsViewStore.cachedViews;
  });

  watch(
    route,
    newVal => {
      tagsViewStore.addCachedView(newVal);
    },
    { immediate: true }
  );

  return cachedView;
};
